/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 鸭叫装饰者
 * @Description *
 * @Package designmodel.composite.wrapper
 * @date 2021/3/2 5:16 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.composite.wrapper;

import designmodel.composite.Quackable;
import designmodel.composite.observer.Observable;
import designmodel.composite.observer.Observer;

public class QuackWrapper implements Quackable {

    Observable observable;

    Quackable duck;
    static int numberOfQuacks;

    //构造
    public QuackWrapper(Quackable duck) {
        this.duck = duck;
    }

    @Override
    public void quack() {
        duck.quack();
        numberOfQuacks++;
    }

    //获取叫声总数
    public static int getQuacks() {
        return numberOfQuacks;
    }

    @Override
    public void registerObserver(Observer observer) {
        observable.registerObserver(observer);
    }

    @Override
    public void notifyObservers() {
        observable.notifyObservers();
    }
}
